home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload Trio 2 / Shareware Overload Trio Volume 2 (Chestnut CD-ROM).ISO / dir42 / doslbs.zip / DOSLIB04.CLA < prev    next >
Text File  |  1994-02-21  |  14KB  |  258 lines

  1.                 MEMBER('DOSLIB')
  2.                 Map
  3.                   Prt:Import_Comma(String,*String[],String,String)
  4.                 .
  5.  
  6. OMIT('╝')
  7. ╔════════════════════════════════════════════════════════════════════════════╗
  8. ║ File_Printer_Setup -                           !Generated Procedure        ║
  9. ╚════════════════════════════════════════════════════════════════════════════╝
  10. Printer_Setup    Procedure(Printer:Controls,Control:File,Printer:Initialise)
  11.  
  12. Printer_Controls Group
  13. Prt:Destination    String(6)
  14. Prt:Filespec       String(64)
  15. Prt:PrinterName    String(30)
  16. Prt:Control_BF     String(30)
  17. Prt:Control_AFT    String(30)
  18. Prt:Lines_Page     Short(60)
  19.                  .
  20. INILine          String(64)
  21. INIVariables     String(30),Dim(8)
  22.  
  23. SCREEN           SCREEN(19,40),PRE(SCR),SHADOW,FALL,CUA,COLOR(112)
  24.                    !style=D:\CLARION\DEVELOP\DOSLIB\CLARION.STY
  25.                    ROW(1,2)    PAINT(1,13),COLOR(2)
  26.                    ROW(1,26)   PAINT(1,14),COLOR(2)
  27.                    ROW(4,4)    PAINT(7,1),COLOR(10)
  28.                    ROW(4,13)   PAINT(5,10),COLOR(10)
  29.                    ROW(4,31)   PAINT(6,7),COLOR(10)
  30.                    ROW(8,5)    PAINT(1,8),COLOR(10)
  31.                    ROW(8,23)   PAINT(2,8),COLOR(10)
  32.                    ROW(9,15)   PAINT(1,8),COLOR(10)
  33.                    ROW(10,13)  PAINT(1,1),COLOR(10)
  34.                    ROW(10,35)  PAINT(1,3),COLOR(10)
  35.                    ROW(1,15)   STRING('Print Setup'),COLOR(2)
  36.                    ROW(10,14)  STRING(':'),COLOR(15)
  37.                    ROW(19,1)   STRING('█▄{38}█'),COLOR(3)
  38.                                REPEAT(18)
  39.                    ROW(1,1)      STRING('█'),COLOR(3)
  40.                    ROW(1,40)     STRING('█'),COLOR(3)
  41.                                .
  42.                    ROW(3,4)    PROMPT('&Output to:'),COLOR(4,5,40,6,7)
  43.                                OPTION,USE(Prt:Destination),IMM
  44.                    ROW(4,5)      RADIO('LPT1'),OVR,COLOR(15,16,37,41,42)
  45.                    ROW(5,5)      RADIO('LPT2'),OVR,COLOR(15,16,37,41,42)
  46.                    ROW(6,5)      RADIO('LPT3'),OVR,COLOR(15,16,37,41,42)
  47.                    ROW(7,5)      RADIO('LPT4'),OVR,COLOR(15,16,37,41,42)
  48.                    ROW(4,23)     RADIO('COM1'),OVR,COLOR(15,16,37,41,42)
  49.                    ROW(5,23)     RADIO('COM2'),OVR,COLOR(15,16,37,41,42)
  50.                    ROW(6,23)     RADIO('COM3'),OVR,COLOR(15,16,37,41,42)
  51.                    ROW(7,23)     RADIO('COM4'),OVR,COLOR(15,16,37,41,42)
  52.                    ROW(9,5)      RADIO('&SCREEN'),COLOR(15,16,37,41,42)
  53.                    ROW(10,5)     RADIO('&FILE'),OVR,COLOR(15,16,37,41,42)
  54.                                .
  55.                      COL(15)   ENTRY(@s20),USE(Prt:Filespec),OVR,COLOR(15,16,37)
  56.                    ROW(12,4)   PROMPT('Li&nes Per Page  :'),COLOR(4,5,40,6,7)
  57.                      COL(21)   ENTRY(@n_2),USE(Prt:Lines_Page),INS,COLOR(8,9,38)
  58.                    ROW(13,4)   PROMPT('Control &Before  :'),COLOR(4,5,40,6,7)
  59.                      COL(21)   ENTRY(@s15),USE(Prt:Control_BF),OVR,COLOR(8,9,38)
  60.                    ROW(14,4)   PROMPT('Control &After   :'),COLOR(4,5,40,6,7)
  61.                      COL(21)   ENTRY(@s15),USE(Prt:Control_AFT),OVR,COLOR(8,9,38)
  62.                    ROW(15,4)   PROMPT('Printer &Name    :'),COLOR(4,5,40,6,7)
  63.                      COL(21)   ENTRY(@s15),USE(Prt:PrinterName),OVR,COLOR(8,9,38)
  64.                      COL(37)   BUTTON(''),KEY(AltF),USE(?Find_Printer),COLOR(17,18,39,19,20)
  65.                    ROW(17,4)   BUTTON('  &Ok  |'),SHADOW,KEY(EnterKey),USE(?Ok),COLOR(17,18,39,19,20)
  66.                      COL(14)   BUTTON(' &Cancel |'),SHADOW,KEY(EscKey),USE(?Cancel),COLOR(17,18,39,19,20)
  67.                      COL(26)   BUTTON(' &Defaults '),SHADOW,USE(?Defaults),COLOR(17,18,39,19,20)
  68.                  .
  69.  
  70.                  CODE
  71.                  If ~Omitted(3) then
  72.                     Printer_Controls = Printer:Controls
  73.                     Do ReadIniFile
  74.                     Printer:Controls = Printer_Controls
  75.                     Return
  76.                  .
  77.  
  78.                  OPEN(Screen)
  79.                  Printer_Controls  = Printer:Controls
  80.                  Do Enable_File
  81.                  Display
  82.  
  83.                  LOOP
  84.                    ACCEPT                                     !Accept input
  85.                    CASE FIELD()
  86.                    OF ?Prt:Destination
  87.                       Do Enable_File
  88.                    OF ?Prt:Filespec
  89.                    OF ?Prt:Lines_Page
  90.                    OF ?Prt:Control_BF
  91.                    OF ?Prt:Control_AFT
  92.                    OF ?Prt:PrinterName
  93.                    OF ?Find_Printer
  94.                       Prt:PrinterName = Select_Printer(Prt:PrinterName,Control:File)
  95.                       Select(?Prt:PrinterName)
  96.                    OF ?Ok
  97.                       Break
  98.                    OF ?Cancel
  99.                       Prt:FileSpec = 'CANCEL'
  100.                       Break
  101.                    Of ?Defaults
  102.                       Do ReadINIFile
  103.                       Do Enable_File
  104.                       Display
  105.                  . .
  106.                  Printer:Controls = Printer_Controls
  107.                  Return
  108.  
  109. Enable_File      Routine
  110.                  Case Clip(Prt:Destination)
  111.                    Of 'LPT1'    ; Disable(?Prt:FileSpec); Prt:FileSpec = 'LPT1'
  112.                    Of 'LPT2'    ; Disable(?Prt:FileSpec); Prt:FileSpec = 'LPT2'
  113.                    Of 'LPT3'    ; Disable(?Prt:FileSpec); Prt:FileSpec = 'LPT3'
  114.                    Of 'LPT4'    ; Disable(?Prt:FileSpec); Prt:FileSpec = 'LPT4'
  115.                    Of 'COM1'    ; Disable(?Prt:FileSpec); Prt:FileSpec = 'COM1'
  116.                    Of 'COM2'    ; Disable(?Prt:FileSpec); Prt:FileSpec = 'COM2'
  117.                    Of 'COM3'    ; Disable(?Prt:FileSpec); Prt:FileSpec = 'COM3'
  118.                    Of 'COM4'    ; Disable(?Prt:FileSpec); Prt:FileSpec = 'COM4'
  119.                    Of 'SCREEN'  ; Disable(?Prt:FileSpec); Prt:FileSpec = 'SCREEN'
  120.                    Of 'FILE'    ; Enable (?Prt:FileSpec);
  121.                  .
  122.                  Exit
  123.  
  124. ReadINIFile      Routine
  125.  
  126.                  IniLine  = Command('CLAPRINTDEVICE',0)
  127.                  Prt:Import_Comma(IniLine,IniVariables[],'<39>',',')
  128.                  Prt:Destination = INIVariables[1]
  129.                  Prt:Lines_Page  = INIVariables[2]
  130.                  Prt:Control_BF  = INIVariables[7]
  131.                  Prt:Control_AFT = INIVariables[8]
  132.  
  133.                  Prt:PrinterName = Command('CLAPRINTERNAME',0)
  134.                  Exit
  135.  
  136. Prt:Import_Comma PROCEDURE(Data:Record,Data:Table,Delimiter:Str,Delimiter:Fld)
  137. !
  138. ! ┌─────────────────────────────────────────────────────────────────────────┐
  139. ! │             Data Extract Procedure 1 - Comma Delimited Fields           │
  140. ! ├─────────────────────────────────────────────────────────────────────────┤
  141. ! │ Procedure Name.: EXT_COMMA_FIELDS                                       │
  142. ! │ Description....: Extracts individual fields from a Comma Delimited File │
  143. ! │ Parameters.....: Data:Table  - Table to hold the fields after extraction│
  144. ! │                  Data:Record - Record containing delimited fields       │
  145. ! │                                                                         │
  146. ! ├─────────────────────────────────────────────────────────────────────────┤
  147. ! │ Algorithm:                                                              │
  148. ! │                                                                         │
  149. ! │ 1. Examine the first character of the record to determine the following │
  150. ! │    (i)   If it is a Quote, then ignore (Processing Loop will pick it up)│
  151. ! │    (ii)  If it is a Comma, then assume a empty field and process it     │
  152. ! │    (iii) Otherwise assume in field processing for numeric value         │
  153. ! │                                                                         │
  154. ! │ 2. Loop until end of record                                             │
  155. ! │    (i)   Examine the character at position (x)                          │
  156. ! │    (ii)  If it is a Quote and Not In-Field Processing, then Skip to     │
  157. ! │          next quote character                                           │
  158. ! │    (iii) If it is a Quote and In-Field processing, then add the field   │
  159. ! │          to the table                                                   │
  160. ! │    (iv)  If it is a Comma and the next character is a Quote, then       │
  161. ! │          ignore it                                                      │
  162. ! │    (v)   If it is a Comma and the next character is not a Quote, then   │
  163. ! │          assume numeric processing                                      │
  164. ! │                                                                         │
  165. ! │ 3. After end of record, add the last field to the data table            │
  166. ! └─────────────────────────────────────────────────────────────────────────┘
  167. !
  168. !  --------------------------------------------------------------------------
  169. !  Local Processing Variables
  170. !  --------------------------------------------------------------------------
  171. !
  172. Pointers         Group,Pre(Ptr)                  ! Record Processing Pointers
  173. Current_Field      Byte                          !   Current Processing Field #
  174. Current_Character  Short                         !   Processing Character (X)
  175. Last_Character     Short                         !   Last Pointer (Y)
  176. Start_Position     Short                         !   Starting Position for Loop
  177. Last_Position      Short                         !   Last Character to Process
  178. In_Field           Byte                          !   Field Type Processing
  179.                  .                               ! End of Group
  180.  
  181. Flg:Not_In_Field Equate(0)                       ! Not in a Field
  182. Flg:In_String    Equate(1)                       ! Processing a String Field
  183. Flg:In_Numeric   Equate(2)                       ! Processing a Numeric Field
  184. !
  185. !  --------------------------------------------------------------------------
  186. !  Code Section
  187. !  --------------------------------------------------------------------------
  188. !
  189.                    CODE
  190.  
  191.                    Ptr:Current_Field        = 0
  192.                    Ptr:Current_Character    = 0
  193.                    Ptr:Last_Character       = 0
  194.                    Ptr:Start_Position       = 0
  195.                    Ptr:Last_Position        = Len(Clip(Data:Record))
  196.                    Ptr:In_Field             = Flg:Not_In_Field
  197.  
  198.                    Clear(Data:Table[])
  199. !
  200. !                  ----------------------------------------------------------
  201. !                  1. Determine the Starting Position for the Parser
  202. !                  ----------------------------------------------------------
  203. !
  204.                    If Data:Record[1] =  Delimiter:Fld or |
  205.                       Data:Record[1] <> Delimiter:Str then
  206.                       Ptr:In_Field = Flg:In_Numeric
  207.                       Do Get_Data_Field
  208.                    Else
  209.                       Ptr:Current_Character = 1
  210.                    .
  211. !
  212. !                  ----------------------------------------------------------
  213. !                  2. Process the Fields
  214. !                  ----------------------------------------------------------
  215. !
  216.                    Loop Until Ptr:Current_Character > Ptr:Last_Position
  217.  
  218.                       If Data:Record[Ptr:Current_Character]    = Delimiter:Str and |
  219.                          Ptr:In_Field = Flg:Not_in_Field then
  220.                          Ptr:In_Field = Flg:In_String
  221.                          Do Get_Data_Field
  222.                       Elsif Data:Record[Ptr:Current_Character] = Delimiter:Str and |
  223.                          Ptr:In_Field <> Flg:Not_in_Field then
  224.                          Ptr:In_Field =  Flg:Not_in_Field
  225.                          Ptr:Current_Character += 1
  226.                       Elsif Data:Record[Ptr:Current_Character] = Delimiter:Fld and |
  227.                          Data:Record[Ptr:Current_Character+1]  = Delimiter:Str then
  228.                          Ptr:In_Field = Flg:Not_in_Field
  229.                          Ptr:Current_Character += 1
  230.                       Elsif Data:Record[Ptr:Current_Character] = Delimiter:Fld and |
  231.                          Data:Record[Ptr:Current_Character+1] <> Delimiter:Str then
  232.                          Ptr:In_Field = Flg:In_Numeric
  233.                          Do Get_Data_Field
  234.                       Else
  235.                          Break
  236.                    .  .
  237.                    Return
  238. !
  239. ! ┌────────────────────────────────────────────────────────────────────────┐
  240. ! │ Subroutine : Get_Data_Field                                            │
  241. ! │ Description: Gets the Data from the Record and Adds to the Table       │
  242. ! └────────────────────────────────────────────────────────────────────────┘
  243. !
  244. Get_Data_Field     Routine
  245.  
  246.                    Ptr:Last_Character       = Ptr:Current_Character + 1
  247.                    Execute Ptr:In_Field
  248.                       Ptr:Current_Character = Instring(Delimiter:Str,Data:Record,1,Ptr:Last_Character)
  249.                       Ptr:Current_Character = Instring(Delimiter:Fld,Data:Record,1,Ptr:Last_Character)
  250.                    .
  251.                    If Ptr:Current_Character = 0 then Ptr:Current_Character = Ptr:Last_Position + 1.
  252.  
  253.                    Ptr:Current_Field     += 1
  254.                    If Ptr:Current_Field  <= Maximum(Data:Table,1) then
  255.                       Data:Table[Ptr:Current_Field] = Sub(Data:Record,Ptr:Last_Character,(Ptr:Current_Character - Ptr:Last_Character))
  256.                    .
  257.                    Exit
  258.